package com.fa4j.product.stock.model;

import com.fa4j.common.base.model.AbstractCmd;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PositiveOrZero;
import lombok.Builder;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

@Data
@Builder
@Schema(description = "商品库存保存参数")
public class StockSaveCmd extends AbstractCmd {

    @NotNull
    @Schema(description = "商品ID")
    private Integer itemId;

    @NotEmpty
    @Schema(description = "商品规格库存列表")
    private List<@Valid SpecStock> specStockList;

    @Schema(description = "商品规格库存")
    public record SpecStock(
            @NotNull
            @Schema(description = "商品规格ID")
            Integer specId,
            @NotNull
            @PositiveOrZero
            @Schema(description = "库存数量")
            BigDecimal quantity
    ) {
    }
}
